Skip to content

fix: support interfaces from different namespaces as additional interfaces#482

Merged
vbreuss merged 2 commits intomainfrom
topic/support-interfaces-from-different-namespaces
Feb 11, 2026
Merged

fix: support interfaces from different namespaces as additional interfaces#482
vbreuss merged 2 commits intomainfrom
topic/support-interfaces-from-different-namespaces

Conversation

@vbreuss
Copy link
Copy Markdown
Contributor

@vbreuss vbreuss commented Feb 11, 2026

Updates the source generator to avoid naming collisions when multiple additional interfaces share the same type name across different namespaces, and adds regression tests to ensure the generated API remains unique and usable.

Key Changes:

  • Track and reuse “used member names” across generated partial extension sources for the same base mock type.
  • When the namespace differs from the main type, include it in the generated name.
  • Add source-generator test coverage validating conflict resolution via indexed naming.
  • Add runtime test ensuring the correct additional-interface setup/verify members are available per mock instance.

@vbreuss vbreuss self-assigned this Feb 11, 2026
Copilot AI review requested due to automatic review settings February 11, 2026 13:29
@vbreuss vbreuss added the bug Something isn't working label Feb 11, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the source generator to avoid naming collisions when multiple additional interfaces share the same type name across different namespaces, and adds regression tests to ensure the generated API remains unique and usable.

Changes:

  • Track and reuse “used member names” across generated partial extension sources for the same base mock type.
  • Add source-generator test coverage validating conflict resolution via indexed naming.
  • Add runtime test ensuring the correct additional-interface setup/verify members are available per mock instance.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
Tests/Mockolate.Tests/MockTests.CreateTests.cs Adds an integration-style test that exercises unique setup/verify member names when additional interfaces have conflicting simple names.
Tests/Mockolate.SourceGenerators.Tests/MockGeneratorTests.cs Adds a generator test asserting indexed filenames and uniquely named setup/verify members for conflicting additional interfaces.
Source/Mockolate.SourceGenerators/Sources/Sources.ForMock.CombinationExtensions.cs Extends generator source emission to accept a shared set of used names rather than recreating it per file.
Source/Mockolate.SourceGenerators/MockGenerator.cs Introduces per-base-type tracking of used member names and passes it into extension generation to prevent partial-type member collisions.

Comment thread Source/Mockolate.SourceGenerators/MockGenerator.cs
Comment thread Tests/Mockolate.SourceGenerators.Tests/MockGeneratorTests.cs
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 11, 2026

Test Results

    21 files  ± 0      21 suites  ±0   5m 51s ⏱️ -21s
 2 729 tests + 2   2 728 ✅ + 2  1 💤 ±0  0 ❌ ±0 
18 317 runs  +10  18 316 ✅ +10  1 💤 ±0  0 ❌ ±0 

Results for commit beafcd4. ± Comparison against base commit 01cf563.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 11, 2026

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.70GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.103
[Host] : .NET 10.0.3 (10.0.3, 10.0.326.7603), X64 RyuJIT x86-64-v3

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Simple_Mockolate 1.595 μs 0.0174 μs 0.0162 μs 0.2270 - 3.73 KB
Simple_Moq 176.615 μs 0.6074 μs 0.5072 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.667 μs 0.0706 μs 0.0660 μs 0.5569 0.0076 9.14 KB
Simple_FakeItEasy 6.457 μs 0.1005 μs 0.0940 μs 0.4959 - 8.11 KB

@vbreuss vbreuss enabled auto-merge (squash) February 11, 2026 13:58
@sonarqubecloud
Copy link
Copy Markdown

@vbreuss vbreuss disabled auto-merge February 11, 2026 14:02
@vbreuss vbreuss merged commit b092f2d into main Feb 11, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/support-interfaces-from-different-namespaces branch February 11, 2026 14:04
@github-actions
Copy link
Copy Markdown

This is addressed in release v1.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants